<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" id="i1" placeholder="请输入0-100的整数">
<input type="button" value="猜一猜" onclick="myfn()">
<div id="d1">

</div>
<script>
    //生成一个0-100的随机整数
    Math.round(Math.random()*100) // 0-100
    let x = parseInt(Math.random()*100)
    alert(x)
    function myfn() {
        // id所对应的元素是页面中唯一对象！可以省略获取对象的过程：document.getElementById("id名称")
        var i = i1.value
        if (i>x){
            d1.innerText = "猜大了"
        }else if(i<x){
            d1.innerText = "猜小了"
        }else{
            d1.innerText = "猜对了"
        }
    }
</script>
</body>
</html>